package com.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mapper.auto.MajorV2Mapper;
import com.model.auto.MajorV2;
import com.model.auto.vo.GetSchoolV2Vo;
import com.model.auto.vo.GetSchoolVo;
import com.service.IMajorV2Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author astupidcoder
 * @since 2022-09-14
 */
@Service
public class MajorV2ServiceImpl extends ServiceImpl<MajorV2Mapper, MajorV2> implements IMajorV2Service {
    @Autowired
    private MajorV2Mapper majorMapper;

    @Override
    public List<MajorV2> getMajorNameList() {
        return majorMapper.getMajorNameList();
    }

    @Override
    public List<MajorV2> getByTypeAndName(String type, String name) {
        return majorMapper.getByTypeAndName(type, name);
    }

    @Override
    public MajorV2 selectByParams(String code, String groupCode, String majorCode) {
        return majorMapper.selectByParams(code, groupCode, majorCode);
    }

    @Override
    public List<Long> selectSchoolId(GetSchoolV2Vo getSchoolVo) {
        if(StringUtils.hasText(getSchoolVo.getMajor1())){
            getSchoolVo.setMajor1("%"+getSchoolVo.getMajor1()+"%");
        }
        if(StringUtils.hasText(getSchoolVo.getMajor2())){
            getSchoolVo.setMajor2("%"+getSchoolVo.getMajor2()+"%");
        }
        if(StringUtils.hasText(getSchoolVo.getMajor3())){
            getSchoolVo.setMajor3("%"+getSchoolVo.getMajor3()+"%");
        }
        return majorMapper.selectSchoolId(getSchoolVo);
    }

    @Override
    public List<Long> selectMajorSchoolId(Integer majorType, String batch, List<String> majors) {
        return majorMapper.selectMajorSchoolId(majorType, batch, majors);
    }
}
